import http from '@/utils/request.js'
/**
 * 发表评论
 * @param {*} target
 * @param {*} content
 */
export const reqAddComment = (target, content) => {
  return http({
    method: 'post',
    url: '/app/v1_0/comments',
    data: {
      target,
      content
    }
  })
}

/**
 * 获取评论列表
 * @param {*} articleId
 * @param {*} offset
 */
export const reqGetComment = (articleId, offset) => {
  return http({
    method: 'get',
    url: '/app/v1_0/comments',
    params: {
      type: 'a',
      source: articleId,
      offset
    }
  })
}

/**
 * 对评论点赞
 * @param {*} commentId
 */
export const reqAddCommentLike = (commentId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/comment/likings',
    data: {
      target: commentId
    }
  })
}

/**
 * 对评论取消点赞
 * @param {*} target
 */
export const reqDeleteCommentLike = (target) => {
  return http({
    method: 'delete',
    url: `/app/v1_0/comment/likings/${target}`
  })
}

/**
 * 获取评论回复列表
 * @param {*} articleId
 * @param {*} offset
 */
export const reqGetCommentReply = (articleId, offset) => {
  return http({
    method: 'get',
    url: '/app/v1_0/comments',
    params: {
      type: 'c',
      source: articleId,
      offset
    }
  })
}

/**
 * 发表评论回复
 * @param {*} target
 * @param {*} content
 */
export const reqAddCommentReply = (target, content, articleId) => {
  return http({
    method: 'post',
    url: '/app/v1_0/comments',
    data: {
      target,
      content,
      art_id: articleId
    }
  })
}
